<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>通用系统后台登陆</title>
<link href="<%=contextPath %>/css/style.css" rel='stylesheet' type='text/css' />
<!-- jqery -->
<script src="<%=contextPath %>/js/jquery-1.8.1.min.js"></script>
<!-- ajax表单提交-->
<script src="<%=contextPath %>/js/jquery.form.js"></script>
<!-- 验证 -->
<script src="<%=contextPath %>/js/jquery.validate.min.js"></script>
</head>
<body>
<script>
	$(document).ready(function(c) {
	 $('#captcha').on('click', function(c){
		 $("#captcha").attr("src",
					'<%=contextPath%>/getCaptcha?t=' + Math.random());
		});	
});
	function username(val){
		if(val=="张三"){
			 $("#tx").attr("src","images/mrtx.png");
		}
	}
</script>
 <!--SIGN UP-->
 <h1>后台通用系统没有权限</h1>
<div class="login-form">
	<!-- <div class="close"> </div> -->
		<div class="head-info">
			<label class="lbl-1"> </label>
			<label class="lbl-2"> </label>
			<label class="lbl-3"> </label>
		</div>
			<div class="clear"> </div>
	<div class="avtar" style="margin-bottom: 20px;">
		<img id ="tx" src="images/avtar.png" />
	</div>
	<form id="submitf">
		<span style="color: red;"></span>
		<input type="text" name="username" class="text" value="" onchange="username(this.value)" style="margin-top: 20px;" />
		<input type="password" name="password" value="" />
		<input type="text" id="code" name="code" value="" class="yzm" onfocus="yzmsb();" style="margin-top:0px; width: 50%;" /><img id="captcha" src="<%=contextPath%>/getCaptcha" style=" float: right; margin-top: 14px; margin-right: 17px; " />
		<div class="signin">
			<input type="submit" value="登陆" />
		</div>
	</form>	
</div>
<script>
	$(function(){
		var a = "<p style='color: red'>";
		$("#submitf").validate({
			rules : {
				username : {
					required : true,
					minlength : 2
				},
				password : {
					required : true,
					minlength :5
				}
			},
			messages : {
				username : {
					required:a+"请输入您的用户名",
					minlength :a+"用户名必须两个字符以上"
				},
				password : {
					required :a+"请输入您的密码",
					minlength :a+"密码必须5个字符以上"
				}
			},
			 submitHandler:function(form){
				 if($("#code").val()==""){
					 $("#code").css("border","1px solid red");
					 return false;
				 }else{
					 $("#code").css("border","");
				 }
				 $(form).ajaxSubmit({
		            	url:'<%=contextPath%>/logins',
		            	type:'post',
		            	dataType:"json",
		            	success:function(data){
		            		if(data.code==200){
		            			location.href = "<%=contextPath%>/index";
		            		}else{
		            			$("#captcha").attr("src",
		            					'<%=contextPath%>/getCaptcha?t=' + Math.random());
		            			$("span").text(data.message);
		            		}
		            	}
	              }); 
	        }
		});
	});
	
	function yzmsb(){
		$("#code").css("border","");
	}
</script>
</body>
</html>